1. Field of the Invention
The present invention relates in general to a microcomputer, and more particularly to a key signal input circuit for a microcomputer, while the number of pins of the microcomputer is reduced.
2. Description of the Prior Art
A microcomputer has commonly been employed in most electronic equipments.
Referring to FIG. 1, there is shown an example of a key signal input circuit for such a microcomputer in circuit form. In FIG. 1, a microcomputer 1 is adapted to output four drive grid signals GS1-GS4 and to input four key signals RS1-RS4. A key matrix circuit 2 includes push button switches S1-S16 that are responsive to the grid signals GS1-GS4 from the microcomputer 1 and to on/off states of the push button switches S1-S16, and outputs the key signals RS1-RS4. The grid signals GS1-GS4 from the microcomputer 1 are transmitted to the key matrix circuit 2, respectively, over four grid lines G1-G4 and through four diodes D1-D4. The key signals RS1-RS4 from the key matrix circuit 2 are transmitted over four return tines R1-R4 to input ports of the microcomputer 1, respectively.
The microcomputer 1 comprises input register 1a for storing temporarily the key signals RS1-RS4 inputted respectively over the return lines R1-R4 and then outputting the key signals RS1-RS4, a microprocessor 1b for sensing on/off states of the push button switches 1-16 in response to the key signals RS1-RS4 from the input register 1a and providing the grid signals GS1-GS4, an output register 1c for storing temporarily the grid signals GS1-GS4 from the microprocessor 1b and then outputting the grid signals GS1-GS4 respectively to the grid lines G1-G4, and a data bus 1d coupled among the input register 1a, the output register 1c and the microprocessor 1b for data input/output to/from the microprocessor 1b.
In key matrix circuit 2, one terminal of each of the push button switches S1-S4 is connected to the grid line G1 and one terminal of each of the push button switches S5-S8 is connected to the grid line G2. Similarly, one terminal of each of the push button switches S9-S12 is connected to the grid line G3 and one terminal of each of the push button switches S13-S16 is connected to the grid line G4. The return lines R1-R4 are arranged perpendicularly to the grid lines G1-G4. The other terminal of each of the push button switches S1, S5, S9 and S13 is connected to the return line R1 and the other terminal each of the push button switches S2, S6, S10 and S14 is connected to the return line R2. Similarly, the other terminal of each of the push button switches S3, S7, S11 and S15 is connected to the return line R3 and the other terminal of each of the push button switches S4, S8, S12 and S16 is connected to the return line R4. As mentioned, the combination of the push button switches with the lines has a key matrix form.
The operation of the construction of FIG. 1 will now be described with reference to FIGS. 2 and 3.
During operation, the grid signals GS1-GS4 are successively outputted from the microprocessor 1b respectively to the grid lines G1-G4 aligned in the horizontal direction in such a manner that high signals of predetermined pulse width t1 are in sequence and applied respectively to the grid lines G1-G4 at a constant interval t2, as shown in FIGS. 2A to 2D. In response to the key signals RS1-RS4 inputted respectively over the return lines R1-R4 aligned in the vertical direction, the microprocessor 1b senses on/off states of the push button switches S1-S16.
For example, as shown in FIG. 3, assuming that the grid signal GS1 is high (logical value "1"), the grid signals GS2-GS4 are all low (logical value "0") and the key signal RS1 of high level is applied to the input register 1a, the microprocessor 1b senses the state (pushed state) of the push button switch S1 as being on. In other words, when the grid signal GS1 is high and the grid signals GS2-GS4 are all low while the push button switch S1 is activated for a period of time t3 as shown in FIG. 2E, the key signal RS1 that is applied to the input register 1a become high as shown in FIG. 2F. This results in the pushed or activated state of the push button switch S1 that is recognized by the microprocessor 1b. At this time, the other key signals RS2-RS4 are all low as shown in FIGS. 2G to 2I, respectively.
In this manner, the microprocessor 1b outputs successively, in order, the grid signals GS1-GS4 of high level respectively to the grid lines G1-G4. The microprocessor 1b determines the activated states of the push button switches S1-S16 in accordance with the input states of the key signals RS1-RS4 corresponding to each event.
Referring to FIG. 4, another example of a key signal input circuit for a microcomputer is shown in circuit form. In FIG. 4, there are no grid lines and only one return line over which a key signal is transmitted for determination of the activated states of push button switches in accordance with its signal magnitude. This results in a reduction in the number of ports of the microcomputer.
A microcomputer 3 has a single input port, and a key matrix circuit 4 consists of a plurality of push button switches 17-21 and a plurality of resistors R1-RG.
The microcomputer 3 includes an analog/digital (A/D) converter 3a for converting a key signal transmitted over the return line from the key matrix circuit 4 into a digital signal and input register 3b for storing temporarily the digital signal from the analog/digital converter 3a and then outputting the digital signal. The microcomputer 3 also includes a microprocessor 3d for discriminating the activated states of the push button switches S17-S21 in accordance with the digital signal from the input register 3b and a data bus 3c coupled between the input register 3b and the microprocessor 3d for transmitting of the digital signal therebetween.
In the key matrix circuit 4, the pull-up resistors R1-R6 are connected in order and in series with respect to one another between a DC power source Vcc and a ground GND. The push button switches S17-21 are connected respectively between the ground GND and respective connection points of adjacent ones of the resistors R1-R6 as shown in FIG. 4.
The operation of the construction of FIG. 4 will now be described.
During operation, if any one of the push button switches S17-S21 is activated, a corresponding one of the series connected resistors R1-R6 is selected, resulting in a variation in the total resistance of the resistors. Then, a voltage that is divided by the varied total resistance is inputted through an input port P to the analog/digital converter 3a in the microcomputer 3. The input voltages is converted into digital data by the analog,/digital converter 3a and the digital data is applied to the input register 3b. The digital data is temporarily stored in the input register 3b and is then transmitted to the microprocessor 3d over the data bus 3c. The microprocessor 3d discriminates the activated states of the push button switches S17-S21 by analyzing the digital data.
However, the above-mentioned techniques have disadvantages as follows. The key signal input circuit in FIG. 1 has a disadvantage, in that, the number of transmission lines for data input/output are large. Namely, the number of the transmission lines required by the microcomputer is eight including 4 grid lines and 4 return lines. The key signal input circuit in FIG. 1 employs 16 available conditions due to a characteristic of the key matrix circuit. Nevertheless 256 (2.sup.8) events corresponding to the eight lines can occur at a maximum. This results in a low degree of efficiency in the circuit. On the other hand, the key signal input circuit in FIG. 4 is desirable in order to reduce the number of ports since only a single line is merely required by the microcomputer. However, this circuit has a disadvantage of limiting the number of events since the activated states of the push button switches must be discriminated on the basis of differences among a series of total resistances. Further, signals of transient state may be produced at a short period by the push button switches and a noise may be introduced from the ground. These disadvantageous can result in a malfunction of the microcomputer.